package com.example.ui.fragment;

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.administrator.sharker_demo.R;
import com.example.models.data.Study.StudyRecyclerviewData;
import com.example.ui.activity.MainActivity;
import com.example.ui.adapter.StudyRecyclerviewAdapter;
import com.example.utils.StudyUtils;

import java.util.ArrayList;

import butterknife.BindView;
/**
 * 董建业  时间:2017/4/12.
 * <p>
 * 课程列表
 */

public class AllDataItemFragment extends TransitionFragment implements StudyUtils.InternetData {

    @BindView(R.id.alldata_item_recyclerview)
    RecyclerView alldataItemRecyclerview;

    @Override
    public int getlayoutid() {
        return R.layout.fragment_alldata_item;
    }

    @Override
    protected void initview(View view) {
        alldataItemRecyclerview.setLayoutManager(new LinearLayoutManager(getContext()));
    }

    @Override
    protected void requestdata() {
        MainActivity activity = (MainActivity) getActivity();
        StudyUtils studyUtils = new StudyUtils();
        studyUtils.setInternetdata(this);
        switch (activity.getAlldatatype()) {
            case 1:
                studyUtils.getlisttrydata();
                break;
            case 5:
                studyUtils.getlistcoursedata();
                break;
            case 9:
                studyUtils.getlisttoppic();
                break;
            default:
                break;
        }
    }

    @Override
    public void data(ArrayList<StudyRecyclerviewData> listdata) {

    }

    @Override
    public void returndata(ArrayList<StudyRecyclerviewData> listdata) {
        alldataItemRecyclerview.setAdapter(new StudyRecyclerviewAdapter(getContext(),listdata,false));
    }
}
